using System;
using System.Collections;
using System.Data;
using CE.Database;
/// <summary>
/// Summary description for UserProfileDB
/// </summary>
/// 
namespace CE.User
{
    public class UserSIRDB
    {
        public UserSIRDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public Int64 Insert(UserSIR usersir)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "[sprocSIRInsertUpdateSingleItem]";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@SIRID", usersir.SIRID);
            _sPara.Add("@FullName", usersir.FullName);
            _sPara.Add("@Email", usersir.Email);
            _sPara.Add("@MobileNumber", usersir.MobileNumber);
            _sPara.Add("@CarRenewalMonth", usersir.CarRenewalMonth);
            _sPara.Add("@PARenewalMonth", usersir.PARenewalMonth);
            _sPara.Add("@MedicalRenewalMonth", usersir.MedicalRenewalMonth);
            _sPara.Add("@Status", usersir.Status);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public UserSIR GetSIR(string Email, string MobileNo)
        {
            UserSIR _sir = null;
            MyDatabase _db = new MyDatabase();
            string _spName = "sprocSIRSelectSingleItem";

            SortedList _spara = new SortedList();
            _spara.Add("@Email", Email);
            _spara.Add("@MobileNo", MobileNo);
            using (DataTable _dt = _db.GetDataTableBySP(_spName, _spara))
            {
                if (_dt != null && _dt.Rows.Count > 0)
                {
                    _sir = new UserSIR();
                    _sir = FillDataRecord(_dt);
                }
            }
            return _sir;
        }

        private UserSIR FillDataRecord(DataTable myDataTable)
        {
            UserSIR mySir = new UserSIR();
            mySir.SIRID = Convert.ToInt64(myDataTable.Rows[0]["SIRID"].ToString());
            mySir.FullName = myDataTable.Rows[0]["FullName"].ToString();
            mySir.Email = myDataTable.Rows[0]["Email"].ToString();
            mySir.MobileNumber = myDataTable.Rows[0]["MobileNumber"].ToString();
            mySir.CarRenewalMonth = Convert.ToInt16(myDataTable.Rows[0]["CarRenewalMonth"].ToString());
            mySir.PARenewalMonth = Convert.ToInt16(myDataTable.Rows[0]["PARenewalMonth"].ToString());
            mySir.MedicalRenewalMonth = Convert.ToInt16(myDataTable.Rows[0]["MedicalRenewalMonth"].ToString());
            mySir.Status = Convert.ToBoolean(myDataTable.Rows[0]["Status"].ToString());
            return mySir;
        }

        public bool Update()
        {
            return true;
        }

        public bool Delete()
        {
            return true;
        }

    }
}